<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>ECharts</title>
    <!-- 引入刚刚下载的 ECharts 文件 -->
    <script src="./package/dist/echarts.js"></script>
</head>

<body>
    <!-- 为 ECharts 准备一个定义了宽高的 DOM -->
    <div id="main" style="width: 600px;height:1000px;"></div>
    <script src="https://code.jquery.com/jquery-3.7.1.js"></script>


    <script type="text/javascript">
        // 获取数据
        $.ajax({
            type: `GET`,
            url: `https://www.zzgoodqc.cn/index.php/index/index/getOrders`,
            dataType: `JSON`,
            success: (e) => {
                console.log(e);
                // 订单数
                let arr = e.data.arr
                // zognjine
                let list = e.data.list

                // 基于准备好的dom，初始化echarts实例
                var myChart = echarts.init(document.getElementById('main'));
                // 指定图表的配置项和数据
                var option = {
                    title: {
                        text: `订购商品数`
                    },
                    tooltip: {
                        trigger: 'item',

                    },
                    legend: {
                        orient: `vertical`,
                        top: '15%',
                        right: '0px',

                    },

                    series: [
                        {
                            name: '订购商品数',
                            type: 'pie',
                            radius: ['30%', '50%'],
                            avoidLabelOverlap: true,   //防止标签间的重叠。
                            label: {
                                show: false,
                                position: 'center'
                            },
                            emphasis: {
                                label: {
                                    show: true,
                                    fontSize: 15,
                                    fontWeight: 'bold',

                                }
                            },
                            labelLine: {
                                show: false
                            },
                            data: [
                                { value: arr[0], name: `4月                      ` + list[0] },
                                { value: arr[1], name: `5月                      ` + list[1] },
                                { value: arr[2], name: `6月                      ` + list[2] },
                                { value: arr[3], name: `7月                      ` + list[3] },
                                { value: arr[4], name: `8月                      ` + list[4] },
                                { value: arr[5], name: `9月                      ` + list[5] }
                            ]
                        }
                    ]
                };
                var option1 = {
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'shadow'
                        }
                    },
                    legend: {},
                    grid: {
                        left: '3%',
                        right: '4%',
                        top: '20%',
                        containLabel: true
                    },
                    xAxis: [
                        {
                            type: 'category',
                            data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
                        }
                    ],
                    yAxis: [
                        {
                            type: 'value'
                        }
                    ],
                    series: [
                        {
                            name: 'Direct',
                            type: 'bar',
                            emphasis: {
                                focus: 'series'
                            },
                            data: [320, 332, 301, 334, 390, 330, 320]
                        },
                        {
                            name: 'Email',
                            type: 'bar',
                            stack: 'Ad',
                            emphasis: {
                                focus: 'series'
                            },
                            data: [120, 132, 101, 134, 90, 230, 210]
                        },
                        {
                            name: 'Union Ads',
                            type: 'bar',
                            stack: 'Ad',
                            emphasis: {
                                focus: 'series'
                            },
                            data: [220, 182, 191, 234, 290, 330, 310]
                        },
                        {
                            name: 'Video Ads',
                            type: 'bar',
                            stack: 'Ad',
                            emphasis: {
                                focus: 'series'
                            },
                            data: [150, 232, 201, 154, 190, 330, 410]
                        },

                    ]
                };

                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option);
                myChart.setOption(option1);
            },
            error: (a) => {

            }
        })


    </script>
</body>

</html>